Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

498
Visualizações
Cypress: Getting "Parameter supplied to cy.request() contained a circular reference at the path specWindow" when using command inside a command

I have 2 different commands that I intend to use inside each other. The 1st one generates an object and the second one uses it to send as body of a cy.request. They look like this

Cypress.Commands.add("objectGeneration", function(search, method, block){
  let body = {}
  if(search === 'something') {
    body.search = search,
    body.method = method,
    body.block = block
  }
  return body
})


Cypress.Commands.add("sendReq", (search, method, block) {
  cy.request({
    method: 'POST',
    URL: 'URL',
    body: cy.objectGeneration(search, method, block)

  })

})

In my test I call them this way (where each testCase variable comes from a helper object I import into my test case.

it("Name of the test", function(){
  cy.sendReq(testCase.search, testCase.method, testCase.block).then((resp => {..}...
})

When trying to run this, I get the following Cypress error:

The body parameter supplied to cy.request() contained a circular reference at the path specwindow body can only be a string or an object with no circular references.

All of this would work fine when objectGeneration was just a function and not a command. I think my issue might have to do with the return in a command. Any suggestions? Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ran into a similar issue trying to send a Decimal value (using decimal.js) as part of the body.

In the end I serialized the object myself and sent it this in the request. In your case I would think that this should also work:

Cypress.Commands.add("sendReq", (search, method, block) {
  const serialized = JSON.stringify(cy.objectGeneration(search, method, block)) 

  cy.request({
    method: 'POST',
    URL: 'URL',
    body: serialized,
    headers: { 'Content-Type': 'application/json' }
  })
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda